<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>Layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../layuiAdmin/layui/css/layui.css" media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
  <style>
    .margin-top {
      margin-top: 20px;
    }

    .h1 {
      font-size: 20px;
      /* padding-left: 50px; */
    }

    .layui-form-label {
      white-space: nowrap;
      text-align: left;
      padding-left: 0;
      width: auto !important;
    }

    .height {
      height: 20px;
    }

    .layui-textarea {
      height: 30px !important;
    }

    .btnbox {
      padding: 20px;
      text-align: center;
    }
  </style>
</head>


<body style="background-color: #fff;">

  <div class="layui-fluid">
    <div class="height"></div>
    <div class="layui-field-box">
      <form action="" class="layui-form">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label for="" class="layui-form-label">抽查人</label>
            <div class="layui-input-inline">
              <select name="modules" lay-verify="required" lay-search="">
                <option value="">直接选择或搜索选择</option>
                <option value="1">机电技术科</option>
                <option value="1">安全质量管理科</option>
              </select>
            </div>
          </div>
          <div class="layui-inline">
            <label for="" class="layui-form-label">抽查部门</label>
            <div class="layui-input-inline" style="width:100px;">
              <select name="modules" lay-verify="required" lay-search="">
                <option value="">直接选择或搜索选择</option>
                <option value="1">机电技术科</option>
                <option value="1">安全质量管理科</option>
              </select>
            </div>
          </div>
        </div>
      </form>

      <table class="layui-hide" id="test" lay-filter="test"></table>
    </div>
    <div class="btnbox">
      <button type="button" class="layui-btn  layui-btn-sm"><i class="layui-icon">&#xe655;</i>保存</button>
      <button type="button" class="layui-btn  layui-btn-sm"><i class="layui-icon">&#xe609;</i>保存并提交</button>
      <button type="button" class="layui-btn  layui-btn-sm"><i class="layui-icon">&#x1006;</i>取消</button>
    </div>
  </div>

  <script type="text/html" id="barDemo">
    <a class=" layui-btn-xs layui-table-link" lay-event="ok">合格</a>
    <!-- <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a> -->
    <a class="layui-table-link layui-btn-xs" lay-event="no">不合格</a>
  </script>

  <script src="../../layuiAdmin/layui/layui.all.js" charset="utf-8"></script>
  <!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->

  <script>
    layui.use(['form', 'table'], function () {
      var table = layui.table
        , form = layui.form
        , layer = layui.layer
        , laydate = layui.laydate;
      laydate.render({
        elem: '#date'
      });
      table.render({
        elem: '#test'
        // , height: '200px'
        , url: '/js/table.json'
        // , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
        , defaultToolbar: ['exports']
        , title: '用户数据表'
        , cols: [[
          { type: 'checkbox', fixed: 'left' }
          , { field: 'id', title: '申请单ID' }
          , { field: 'id', title: '隐患ID' }
          , { field: 'content', title: '隐患内容' }
          , { field: 'status', title: '状态' }
          , { fixed: 'right', title: '操作', width: 200, align: 'center', toolbar: '#barDemo' } //这里的toolbar值是模板元素的选择器

        ]]
        , page: {
          limit: 1
          , limits: [1, 10, 20]
        }
      });

      //监听行工具事件
      table.on('tool(test)', function (obj) {
        var data = obj.data;
        //console.log(obj)
        if (obj.event === 'ok') {
          layer.confirm('确认合格吗', function (index) {
            // obj.del();
            layer.close(index);
          });
        } else if (obj.event === 'no') {
          //新建
          layer.open({
            type: 2,
            zIndex: layer.zIndex, //重点1
            title: '隐患编辑',
            shadeClose: true,
            // shade: true,
            maxmin: false, //开启最大化最小化按钮
            area: ['60%', '90%'],
            content: '/page/隐患/隐患录入.html',
            success: function (layero) {
              //layer.setTop(layero); //重点2
            },
            end: function () {
              window.location.reload();
            }

          });
        }
      });
    });
  </script>

</body>

</html>